using System;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
	/**
	 * Classname : Nguoidung
	 * Version information :1.0
	 * Date  :26-09-2006
	 * Copyright notice : 
	 */
	
	public class DATrangThai : DbObject
	{
        protected SqlConnection connec;

        public DATrangThai(SqlConnection Connection)
		{
            connec = Connection;
		}
        // return only the record with the specified ID!!!!!!!!!!!
        public DataSet LayDanhSachTrangThaiID(int LevelID)
        {
            // create the parameter
            SqlParameter[] parameters = { new SqlParameter("@LevelID", SqlDbType.Int, 4) };
            parameters[0].Value = LevelID;

            DataSet dsLevel = RunProcedure("sp_TrangThai_loadLayDanhSachTrangThaiByLevelID", parameters, "TB_TrangThai", connec);
            return dsLevel;
        }
        /// <summary>
        /// Created by LinhDH 2012.08.30
        /// </summary>
        /// <param name="LevelID"></param>
        /// <param name="ip_str_ismain_yn"></param>
        /// <returns></returns>
        public DataSet LayDanhSachTrangThaiIDandIsMainYN(int LevelID, bool ip_str_ismain_yn)
        {
            // create the parameter
            SqlParameter[] parameters = { new SqlParameter("@LevelID", SqlDbType.Int, 4),
                                          new SqlParameter("@IsMain", SqlDbType.Bit, 2)
                                        };
            parameters[0].Value = LevelID;
            parameters[1].Value = ip_str_ismain_yn;
            DataSet dsLevel = RunProcedure("sp_TrangThai_loadLayDanhSachTrangThaiByLevelIDandIsMain", parameters, "TB_TrangThai", connec);
            return dsLevel;
        }
        public DataRow loadTrangThaiID(int TrangThaiID)
        {
            DataRow dr = null;
            try{
                // create the parameter
                SqlParameter[] parameters = {
                                                new SqlParameter("@TrangThaiID", SqlDbType.Int, 4)
                                            };
                parameters[0].Value = TrangThaiID;
                using (DataSet dsLevel = RunProcedure("sp_TrangThai_loadTrangThaiID", parameters, "TB_TrangThai", connec))
                {
                    dr = dsLevel.Tables[0].Rows[0];
                }
            }
            catch{}
            return dr;
        }
        //public DataRow loadTrangThaiGoiID(int TrangThaiID)
        //{
        //    DataRow dr = null;
        //    try
        //    {
        //        // create the parameter
        //        SqlParameter[] parameters = {
        //                                        new SqlParameter("@TrangThaiID", SqlDbType.Int, 4)
        //                                    };
        //        parameters[0].Value = TrangThaiID;
        //        using (DataSet dsLevel = RunProcedure("sp_TrangThai_loadTrangThaiID", parameters, "TB_TrangThai", connec))
        //        {
        //            dr = dsLevel.Tables[0].Rows[0];
        //        }
        //    }
        //    catch { }
        //    return dr;
        //}
        public DataRow loadTrangThaiIDByLevelMain(int LevelID)
        {
            DataRow dr = null;
            try
            {
                // create the parameter
                SqlParameter[] parameters = {   new SqlParameter("@LevelID", SqlDbType.Int, 4)
                                            };
                parameters[0].Value = LevelID;
                using (DataSet dsLevel = RunProcedure("sp_TrangThai_loadTrangThaiIDByLevelMain", parameters, "TB_TrangThai", connec))
                {
                    dr = dsLevel.Tables[0].Rows[0];
                }
            }
            catch { }
            return dr;
        }

	}
}